package com.js.service.bot.core;

import com.js.domian.entity.CommandEntity;
import com.js.mapper.bot.CommandMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
public class CommandService {

    @Resource
    private CommandMapper commandMapper;

    public List<CommandEntity> getCommandList(CommandEntity entity){
        return commandMapper.getCommandList(entity);
    }

    @Transactional(rollbackFor = Exception.class)
    public boolean addCommand(CommandEntity entity){
        try {
            commandMapper.addCommand(entity);
            return true;
        }catch (Exception e){
            return false;
        }
    }

    public List<CommandEntity> getCommand(CommandEntity entity){
        return commandMapper.getCommand(entity);
    }

    @Transactional(rollbackFor = Exception.class)
    public boolean deleteCommand(CommandEntity entity){
        try {
            commandMapper.deleteCommand(entity);
            return true;
        }catch (Exception e){
            return false;
        }
    }
}
